// async function firstAsync() {
//     return 27
// }
// // 如果返回值不适promise会转换成Promise.resolve  等同于：
// async function firstAsync() {
//     return Promise.resolve(27)
// }


// firstAsync(); //不会输出
// console.log(firstAsync()); //加了async,返回一个promise对象,status是resovled
// console.log(firstAsync() instanceof Promise); //true
// firstAsync().then(val => {
//     console.log(val); //打印出27
// })

// async function firstAsync() {
//     let promise = new Promise((resolve, reject) => {
//         setTimeout(function () {
//             resolve('now it is done')
//         }, 1000)
//     });
//     promise.then(val => {
//         console.log(val);

//     })
//     console.log(2);
//     return Promise.resolve(3)
// }
// firstAsync().then(val => {
//     console.log(val);
//     //输出2,3,一秒后输出now it is done
// })



async function firstAsync() {
    let promise = new Promise((resolve, reject) => {
        setTimeout(function () {
            resolve('now it is done')
        }, 1000)
    });
    let result = await promise
    console.log(result);
    console.log(2)
    return Promise.resolve(3);
}
firstAsync().then(val => {
    console.log(val);
    //输出now it is done,2,3
})